{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ae7815fc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 3 µs, sys: 0 ns, total: 3 µs\n",
      "Wall time: 6.44 µs\n",
      "开始爬取ing\n",
      "中国人民大学 | RENMIN UNIVERSITY of CHINA\n"
     ]
    }
   ],
   "source": [
    "%time\n",
    "from selenium import webdriver\n",
    "\n",
    "### 超变量，对Selenium进行提前设置\n",
    "options = webdriver.ChromeOptions()\n",
    "options.add_argument('--disable-dev-shm-usage')\n",
    "options.add_argument('--no-sandbox') # 解决DevToolsActivePort文件不存在的报错\n",
    "options.add_argument('window-size=1600x900') # 指定浏览器分辨率\n",
    "options.add_argument('--disable-gpu') # 谷歌文档提到需要加上这个属性来规避bug\n",
    "options.add_argument('--hide-scrollbars') # 隐藏滚动条, 应对一些特殊页面\n",
    "options.add_argument('blink-settings=imagesEnabled=false') # 不加载图片, 提升速度\n",
    "options.add_argument('--headless') # 浏览器不提供可视化页面. linux下如果系统不支持可视化不加这条会启动失败\n",
    "\n",
    "driver = webdriver.Chrome(options=options,executable_path='./chromedriver')\n",
    "print(\"开始爬取ing\")    \n",
    "driver.get('https://www.ruc.edu.cn/')\n",
    "print(driver.title)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "398242aa",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
